package bl.client;

import java.net.MalformedURLException;
import java.rmi.AlreadyBoundException;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.sql.SQLException;
import client.boot.BLServiceManager;
import o.客户类型;
import server.boot.ServiceLoader;
import vo.ClientVo;
import vo.Vo;
import db.Database;
import dbservice.client.ClientDBService;
import blservice.client.ClientBLService;

public class ClientBLDriver {
	ClientBLService bl;
	ClientDBService db;
	public static void main(String args[]) throws MalformedURLException, NotBoundException, SQLException, AlreadyBoundException{
		
		ClientBLDriver d = new ClientBLDriver();
		try {
			d.drive();
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	void drive() throws RemoteException, MalformedURLException, NotBoundException, SQLException, AlreadyBoundException{
		//环境初始化
				Database.iniDatabase("localhost", 3306, "seac2", "seac2", "seac2");
				ServiceLoader.iniServiceLoader();
				BLServiceManager.setServerIP("localhost");
				bl=BLServiceManager.getClientBLService(null);
		
		ClientVo vo=new ClientVo();
		vo.setOperator("clientBLDriver");
		vo.set地址("南大");
		vo.set姓名("弓长月月鸟");
		vo.set应付(0);
		vo.set应收(0);
		vo.set应收额度(0);
		vo.set电子邮箱("123456789@qq.com");
		vo.set电话("13013752103");
		vo.set类型(客户类型.进货商);
		vo.set级别(5);
		vo.set编号("00001");
		vo.set邮编("210023");
		vo.set默认业务员("默认业务员");
		
		System.out.println("addClient:");
		Vo result;
		result = bl.addClient(vo);
		if(result.isSuccessed())
			System.out.println("添加成功");
		else 
			System.out.println(result.getFailMessage());
		
		System.out.println("updateClient:");
		result = bl.updateClient(vo);
		if(result.isSuccessed())
			System.out.println("更新成功");
		else 
			System.out.println(result.getFailMessage());
	
		System.out.println("deleteClient:");
		result = bl.deleteClient(vo);
		if(result.isSuccessed())
			System.out.println("删除成功");
		else 
			System.out.println(result.getFailMessage());
		System.exit(0);
	}
}
